<script  setup>
    import {ref,reactive,computed,h, onMounted, nextTick} from 'vue';
    import io from 'socket.io-client';
    const baseBackEndServerUrl = "http://localhost:3000";
    var socket =io(baseBackEndServerUrl)
    socket.on("connect_error", (err) => {
        console.log("connect _error",err);
    });
    /**
     * 前端连接服务器
     */
    socket.on('connect',()=>{
        console.log("Connected to server");
    })
    socket.on('disconnect',()=>{
        console.log("disconnect from server");
    })
    const sendStr = function(){
        socket.emit('messageData',"client send string to server");
        console.log("sendStr to server.");
    }
    

</script>

<template>
    <div>
        <button @click="sendStr()">sendStr</button>
    </div>
</template>